home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
163
< prev
next >
Wrap
Text File
|
1996-08-06
|
3KB
|
60 lines
Newsgroups: comp.std.c
Path: phcoms4.seri.philips.nl!panther!baynes
From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
Subject: Re: atexit() and return from main()
Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
Message-ID: <DLMLL6.A0H@ukpsshp1.serigate.philips.nl>
Date: Tue, 23 Jan 1996 08:43:54 GMT
References: <4dhfja$j50@fg70.rz.uni-karlsruhe.de> <4diicg$i9e@lyra.csx.cam.ac.uk> <TANMOY.96Jan22084309@qcd.lanl.gov>
Organization: Philips Semiconductors, Southampton, UK
X-Newsreader: TIN [version 1.2 PL2]
Tanmoy Bhattacharya (tanmoy@qcd.lanl.gov) wrote:
: --text follows this line--
: In article <DLKrx7.6p6@ukpsshp1.serigate.philips.nl>
: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes:
: <snip>
: <snip>
: : main() calls setjmp() and then calls exit(). An atexit() function
: : calls longjmp() and returns to main(). This repeats (or does it?)
: : Neither of these is permitted in any sense that I understand!
: : 7.10.4.3: If more than one call to the exit function is executed by
: : a program, the behaviour is undefined. No `permission by omission'
: : that I can see.
: In this example what happens if no second call to exit is been made (after
: longjumping back to main the program does not attempt to call exit again -
: instead it keeps executing indefinately)?
: I don't understand the question: are you asking what happens if a
: program keeps executing indefinitely? Well, it just keeps executing
: indefinitely. After that infinite period, the rest of the exit
: processing happens and a return status is indicated to the rts.
The question I am asking is if:
main() calls setjmp() and then calls exit(). An atexit() function
calls longjmp() and returns to main(). main() then continues to
execute other code. Is the execution of this code defined behaviour
(so long as no attempt is made to exit again)?
[Note: There is a large class of programs that never exit at all (including
embeded systems and some daemons). They either have the power turned off or are
signalled to death. These are usually accepted as having well defined
behaviour (at least untill the point the power goes of). I agree it would
be perverse of such a program to make exactly one call to exit and then
abandon it by a long jump from an atexit function to main. One can also
construct programs that do this longjump and terminate later by calling abort.
However I think it is reasonable to ask if it is defined what happens after the
longjump in the example is made.]
A related question - does undefined behaviour invalidate (make undefined) all
defined behaviour that has gone before? If so does this mean that any program
that does not exit() or return from main have any defined behaviour?
--
Stephen Baynes baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton My views are my own.
United Kingdom